<template>
  <div class="app-container">
    <div class="filter-container">
    <el-descriptions class="margin-top" :title="$t('bs.systemInformation')" :column="1"   border>
      <template slot="extra">
<!--        <el-button type="primary" size="small">操作</el-button>-->
      </template>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-tickets"></i>
          {{$t('bs.BackendVersion')}}
        </template>
        <el-tag size="small">{{ver}}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-tickets"></i>
          {{$t('bs.UIVersion')}}
        </template>
        <el-tag size="small">1.5.3</el-tag>
      </el-descriptions-item>
    </el-descriptions>

      <el-descriptions class="margin-top" :title="$t('bs.manualUpdate')" :column="3"   border style="margin-top: 30px">
        <template slot="extra">
          <!--        <el-button type="primary" size="small">操作</el-button>-->
        </template>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-office-building"></i>
            上传升级文件<span style="color: #cc0033;padding-left: 30px">{{msg}}</span>
          </template>
          <el-button :loading="showup" type="primary" size="small" @click="importFile">{{$t('bs.upload')}}</el-button>
        </el-descriptions-item>
      </el-descriptions>
    </div>
    <el-upload
        ref="uploadRef"
        style="width: 0;height: 0;visibility: hidden"
        :data="updata"
        :headers="upheaders"
        name="filelist"
        :on-remove="()=>{showup=false}"
        multiple
        :on-progress="()=>{showup=true}"
        :action="updateUrl"
        :on-success="handleSuccess"
    />
  </div>
</template>
<script>
import {getver} from '@/api/common'
import {getToken} from "@/utils/auth";
export default {
  name: "sysver",
  data:function (){
    return {
      ver:"",
      msg:"",
      upheaders: {},
      updata: {},
      showup: false,
    }
  },
  computed:{
    updateUrl:{
      get:function (){
        return process.env.VUE_APP_BASE_URL+'/api/app/update'
      }
    }
  },
  mounted() {
    getver().then((res)=>{
      this.ver=res.data
      console.log(res)
    })
  },
  methods:{

    importFile() {
      this.upheaders = {
        AccessToken: getToken()
      }

      this.updata = {
        // doc_id: item.id,
        // station_id: this.station_id
      }
      this.$refs.uploadRef.$refs['upload-inner'].$refs.input.click()
    },
    handleSuccess(res1) {
      this.showup=false
      this.msg=res1.msg;
      this.$message.info(res1.msg)
    },
  }
}
</script>



<style scoped>

</style>
